{% assign urlParts = page.url | split: '/' %}
{% assign activePlatform = urlParts[1] %}
{% assign activeHub = urlParts[3] %}

{% assign platform = site.data.routes.platforms | where: "href", activePlatform | first %}

{% assign hub = platform.hubs | where: "href", activeHub | first %}

<h1 class="title">{{ hub.title }}</h1>

<p>{{ hub.description }}</p>

{% if hub.articles %}
    {% assign sortedSectionsAndArticles = hub.sections | concat: hub.articles | sort: 'title' %}
{% else %}
    {% assign sortedSectionsAndArticles = hub.sections | sort: 'title' %}
{% endif%}

<section>
    <div class="cards-group">
        {% for item in sortedSectionsAndArticles %}
            {% if item.articles %}
                {% include section-card.html platform=activePlatform hub=hub.href section=item.href title=item.title %}
            {% else %}
                {% include article-card.html hub=hub.href href=item.href title=item.title platform=activePlatform %}
            {% endif %}
        {% endfor %}
    </div>
</section>
